<template>
  <div>
    <van-address-list
      v-model="chosenAddressId"
      :list="list"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit"
    />

  </div>
</template>

<script>
  export default {
    data() {
      return {
        chosenAddressId: '1'
      }
    },
    computed: {
      list() {
        return this.$store.state.address.addressList 
      }
    },
    methods: {
      onAdd(){ //新增
        this.$router.push({
          path:'/address/detail',
          query:{
            idx:-1
          }
        })
      },
      onEdit(item, index){ //编辑
        console.log(item,index);
        this.$router.push({
          path:'/address/detail',
          query:{
            idx:index
          }
        })
      }
    },
  }
</script>

<style lang="less" scoped>

</style>